How should I study?

- Notes + Lecture slides
- Book
- Practice
- Office hours

- Second Java program: volume of a sphere

First logical section: Introduce your variables
Input (Radius) + output variables (Volume) + Constant (PI)

Second logical section: business logic
Formula (4/3 * PI * radius * ...)

Third logical section: Produce an output
System.out.print

Example#1: SphereVolume.java

- Primitive data types (8)

4 for ints: byte, short, int, long
2 for floating point values: float, double

byte (8 bits)
short (16)
int (32)
long (64)

1 bit ---> 0 or 1 (2 unique values)

2 bits ---> 4 unique values 
0	0
0	1
1	0	
1	1

n bits ---> 2^n values

byte: n = 8 ----> 2^8 = 256

My recommendation: 
for integer values, use int
for floating values, use double

Example#2: FloatDemo.java


Literal value: 23.5 floating point values are by default double unless you put an f or F at the end
23.5f or 23.5F

Integer literal values: 23 are by default int unless you append l or L to the end to make them long
23l or 23L

character: char
Unicode character set (16 bits ---> 65,000 characters)


'0' < '1' < ... < '9'	'A' < 'B' < .... < 'Z'		'a' < 'b' .... 'z'
48     49	  57	65     66	    90	 	97    98 	122

boolean: true or false

- Modulo operator: 
a % b

if a = b*k + remainder ==> a % b = remainder
17 = 4*4 + 1 ==> 17 % 4 = 1

3 % 8 ?
3 = 0*8 + 3 ==> 3 % 8 = 3
if a < b and I do a % b = a


14 + 4 = 18
14 + 4.0 = 18.0

7 / 2 = 3
7.0 / 2 = 3.5


14 + 4 / 2 
If + is performed first, answer = 9
If / goes first, answer = 16

- Variable appearing on both sides of an assignment statement
int val = 2;
val = val + 1; // val += 1;
System.out.println(val); // 3




